# Stage 1
FROM golang:1.16.6-alpine3.14 as builder

WORKDIR /app

COPY . .

RUN go env -w GO111MODULE=on
RUN go env -w GOPROXY=https://goproxy.cn,direct
RUN go mod tidy
RUN go build

# Stage 2

FROM alpine:3.15.0 as prod

LABEL maintainer="Tankk<1253871819@qq.com>"

WORKDIR /app

# 设置时区
RUN echo "Asia/Shanghai" > /etc/timezone && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 

COPY --from=builder /app/go-fiber-ip2region .
COPY --from=builder /app/ip2region.db .

# 基础配置
ENV COMMON_PORT=3000

# 高德web服务key
ENV AMAP_KEY=xxxx

EXPOSE 3000

CMD ["./go-fiber-ip2region"]